<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorator="themes/default/layout/public">

<head>
    <link th:href="@{/static/js/summernote/summernote.css}" rel="stylesheet"/>
</head>
<div  layout:fragment="content">
    <div class="row mt-10">
        <div class="col-xs-12 col-md-9 main">
            <div th:if="${#lists.size(categories)>0}" class="widget-category clearfix">
                <div class="col-sm-12">
                    <ul class="list">
                        <li th:class="${condition.category == null}?'active'"><a href="/questions">全部</a></li>
                        <li th:each="category:${categories}" th:classappend="${category.id == condition.category?.id}?'active'"><a th:href="|/questions/${category.slug}|" th:text="${category.name}"></a></li>
                    </ul>
                </div>
            </div>
            <ul class="nav nav-tabs mb-10 mt-20">
                <li th:classappend="${condition.filter == 'newest'}?'active'" ><a  th:href="|${#request.getRequestURI()}?page=1&size=${questions.size}&categoryId=${condition.categoryId}&|">最新问题</a></li>
                <li th:classappend="${condition.filter == 'newanswer'}?'active'" ><a  th:href="|${#request.getRequestURI()}?page=1&size=${questions.size}&categoryId=${condition.categoryId}&filter=newanswer|">最新回答</a></li>
                <li th:classappend="${condition.filter == 'mostview'}?'active'" ><a  th:href="|${#request.getRequestURI()}?page=1&size=${questions.size}&categoryId=${condition.categoryId}&filter=mostview|">最多查看</a></li>
                <li th:classappend="${condition.filter == 'mostanswer'}?'active'" ><a  th:href="|${#request.getRequestURI()}?page=1&size=${questions.size}&categoryId=${condition.categoryId}&filter=mostanswer|">最多回答</a></li>
                <!--<li th:classappend="${condition.filter == 'hottest'}?'active'" ><a th:href="|${#request.getRequestURI()}?page=1&size=${questions.size}&categoryId=${condition.categoryId}&filter=hottest&|">热门的</a></li>-->
                <li th:classappend="${condition.filter == 'reward'}?'active'" ><a th:href="|${#request.getRequestURI()}?page=1&size=${questions.size}&categoryId=${condition.categoryId}&filter=reward|">悬赏的</a></li>
                <li th:classappend="${condition.filter == 'unAnswered'}?'active'"><a  th:href="|${#request.getRequestURI()}?page=1&size=${questions.size}&categoryId=${condition.categoryId}&filter=unAnswered|">未回答的</a></li>
                <li th:classappend="${condition.filter == 'resolved'}?'active'"><a  th:href="|${#request.getRequestURI()}?page=1&size=${questions.size}&categoryId=${condition.categoryId}&filter=resolved|">已解决</a></li>
            </ul>
            <div class="stream-list question-stream">
                <section th:each="question:${questions}" class="stream-list-item">
                    <div class="qa-rank">
                        <div th:class="${question.status==2}?'answers solved':'answers'" th:classappend="${#sets.size(question.answers)>0}?'answered'">
                            <th:block th:text="${#sets.size(question.answers)}"></th:block><small th:text="${question.status==2}?' 解决 ':' 回答 '"></small>
                        </div>
                        <div class="views hidden-xs">
                            <th:block th:text="${question.views}"></th:block><small>浏览</small>
                        </div>
                    </div>
                    <div class="summary">
                        <ul class="author list-inline">
                            <li>
                                <a th:href="|space/${question.user.id}|" target="_blank" th:text="${question.user.nickname}"></a>
                                <span class="split"></span>
                                <span class="askDate" th:text="${#dates.format(question.createdAt,GlobalSetting.time.dateFormat+' '+GlobalSetting.time.timeFormat)}"></span>
                            </li>
                        </ul>
                        <h2 class="title">
                            <span th:if="${question.price>0}" class="text-gold"><i class="fa fa-database"></i><th:block th:text="|${question.price}|"/></span>
                            <a th:href="|/question/${question.id}|" target="_blank"  th:text="${question.title}"></a>
                        </h2>
                        <ul th:if="${#sets.size(question.tags)>0}" class="taglist-inline ib">
                            <li th:each="tag:${question.tags}" class="tagPopup"><a class="tag" target="_blank" th:href="|/topic/${tag.id}|" th:text="${tag.name}"></a></li>
                        </ul>
                    </div>
                </section>

            </div><!-- /.stream-list -->

            <div class="text-center" >
                <ul class="pagination">
                    <li th:onclick="'javascript:goToPage(1)'" class="page-item" th:classappend="${questions.number+1 == 1}?disabled:''">
                        <a class="page-link" th:href="|?page=1&size=${questions.size}&categoryId=${condition.categoryId}&filter=${condition.filter}|" rel="prev">‹</a>
                    </li>
                    <li th:each="i:${#numbers.sequence(questions.number+1-6,questions.number+6)}" class="page-item" th:classappend="${questions.number+1 == i}?'active':''" th:if="${i>0 and i<=questions.totalPages}">
                        <a class="page-link" th:href="|?page=${i}&size=${questions.size}&categoryId=${condition.categoryId}&filter=${condition.filter}|" th:text="${i}"></a>
                    </li>
                    <li th:onclick="'javascript:goToPage('+${questions.totalPages}+')'" class="page-item" th:classappend="${questions.number+1 == questions.totalPages}?disabled:''">
                        <a class="page-link" th:href="|?page=${questions.totalPages}&size=${questions.size}&categoryId=${condition.categoryId}&filter=${condition.filter}|" rel="next">›</a>
                    </li>
                </ul>
            </div>
        </div><!-- /.main -->
        <div class="col-xs-12 col-md-3 side">
            <div class="side-alert alert alert-warning">
                <p style="text-align: center;">今天，遇到了什么问题呢？</p>
                <a href="/question/create" class="btn btn-primary btn-block mt-10">立即提问</a>
            </div>
            <th:block th:include="themes/default/layout/auth_menu"></th:block>
            <div class="widget-box">
                <h2 class="h4 widget-box-title">热议话题 <a href="{{ route('website.topic') }}" title="更多">»</a></h2>
                <ul class="taglist-inline multi">
                    <li th:each="hotTag:${hotTags}" class="tagPopup"><a class="tag" data-toggle="popover"  th:href="|/topic/${hotTag.id}|" th:text="${hotTag.name}"></a></li>
                </ul>
            </div>

            <div class="widget-box mt30">
                <h2 class="widget-box-title">
                    活跃用户
                    <a href="/users" title="更多">»</a>
                </h2>
                <ol class="widget-top10">
                    <li th:each="hotUser:${hotUsers}" class="text-muted">
                        <img class="avatar-32" th:src="${hotUser.avatar}">
                        <a th:href="|/space/${hotUser.id}|" class="ellipsis" th:text="${hotUser.nickname}"></a>
                        <span class="text-muted pull-right"><th:block th:text="${hotUser.data.credit}"></th:block> 经验</span>
                    </li>

                </ol>
            </div>

        </div>
    </div>
</div>